<template>
  <div
    v-if="fullscreen"
    v-loading.fullscreen="loading"
    :element-loading-text="loadingText"
    :element-loading-spinner="loadingSpinner"
    element-loading-svg-view-box="-10, -10, 50, 50"
    :element-loading-background="bgColor"
    style="width: 100%; height: 100%"
  >
    <slot />
  </div>
  <div
    v-else
    v-loading="loading"
    :element-loading-text="loadingText"
    :element-loading-spinner="loadingSpinner"
    element-loading-svg-view-box="-10, -10, 50, 50"
    :element-loading-background="bgColor"
    style="width: 100%; height: 100%"
  >
    <slot />
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  name: 'AppLoading',
  props: {
    loading: {
      type: Boolean,
      default: true
    },
    bgColor: {
      type: String
    },
    loadingText: {
      type: String,
      default: 'Loading...'
    },
    fullscreen: {
      type: Boolean,
      default: false
    },
    loadingSpinner: {
      type: String,
      default: `
      <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }
  },
  setup() {
    return {}
  }
})
</script>

<style scoped lang="scss"></style>
